<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>待付款申请-批量添加审核人</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=f5a12a1d">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style type="text/css">
        .blockElement {
            position: fixed !important;
            top: 50% !important;
        }

        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .table-detail td.td-value2 {
            padding: 1px !important;
            text-align: left !important;
        }

        .pull-left {
            float: left;
            padding-left: 6px;
        }

        .td-value2 input {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
        }

        .td-value2 select {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
            color: #2a8cec;
        }

        .lineOne {
            text-align: left;
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .user:hover {
            background-color: #cfd4d1;
        }

        .userbox .select.user {
            color: #fff;
            background-color: #045B9E;
        }

        .span-btn {
            position: absolute;
            left: 18px;
            margin-top: 0px;
            cursor: pointer;
        }

        .auditorName {
            text-align: center;
        }

        .IcoNormal {
            float: left;
            border-bottom: 0px;
            border-left: 0px;
            background-color: transparent;
            width: 16px;
            height: 16px;
            vertical-align: middle;
            border-top: 0px;
            border-right: 0px;
            background-image: url(/dist/img/upload_normal.gif);
            background-repeat: no-repeat;
            float: left;
        }

        .progressobj {
            height: 20px;
        }

        .progressobj .delfile {
            float: left;
            margin-left: 10px;
        }

        .select {
            color: #fff;
            background-color: #045B9E;
        }

        td .sp-value {
            display: inline-block;
            padding-left: 6px;
            word-wrap: break-word;
        }

        td {
            color: #2a8cec;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: black;
        }

        .table-detail-payee:nth-child(even) td.td-title {
            background-color: white;
        }

        .printDiv {
            display: none;
        }

        .printInput {
            width: 200px;
        }

        .printBtn {
            margin: 0 auto;
            display: block;
        }

        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            display: block;
            padding: 0 4px;
            height: 22px;
            line-height: 22px;
            padding-left: 15px;
            margin: 0 auto;
            width: 70px;
            margin-top: 2px;
            border-radius: 4px;
        }

        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }

        #divUploadedFiles {
            /*padding: 4px;*/
            padding-bottom: 0;
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 6px;
            height: 6px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 0px;
        }

        .moreListData {
            position: absolute;
            top: 30px;
            z-index: 111;
            display: none;
        }

        .moreListData .item {
            width: 100%;
            height: 30px;
            line-height: 30px;
        }

        .moreListData .item span {
            margin-right: 5px;
        }

        .ui_main {
            vertical-align: top;
        }
    </style>
</head>
<body>
<iframe id="ifAttach" style="display:none"></iframe>
<div class="layout" style="left:0px;top:0px;right:0px;bottom:0px;" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>
    <div class="center" style="padding-left:8px;padding-right:8px;">
        <table class="table-detail no-print" style="border-top-width:0px;table-layout: auto;">
            <tr>
                <td class=" td-module" colspan="5" style="background: yellow;">审批进度</td>
            </tr>
            <tr>
                <td class="td-title" style="width:50px;">审核顺序</td>
                <td class="td-title" style="width:50px;">审核人员</td>
                <td class="td-title" style="width:40px;">审核状态</td>
            </tr>
            <tr v-for="(item,i) in money.auditors">
                <td>
                    <span style="font-size:20px;" v-if="pageType=='edit'" class="span-btn"
                              @click="addItem('auditors','Audit')"> + </span>
                    <span>第{{i+1}}审核人</span>
                    <span style="font-size:20px;left: 104px;" v-if="pageType=='edit'"
                          class="span-btn"
                          @click="delItem('auditors',i,'审核人')"> - </span>
                </td>
                <td>
                    <input v-if="pageType=='edit'" class="auditorName" type="text"
                           :value="item.auditorName" :idx="i"/>
                    <span v-else>{{item.auditorName}}</span>
                </td>
                <td>
                    <span>未提交</span>
                </td>
            </tr>
        </table>
    </div>
    <div class="south no-print" style="height:50px;line-height:50px;text-align:center;">
        <input type="button" style="margin-left:20px;" v-if="pageType=='edit'"
               value="提交" class="btn oaBtn btn-sm" @click="save">
    </div>
</div>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=63aed32f"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/dist/js/pages/apply/money/class.js?v1.0"></script>
<script type="text/javascript" src="/dist/js/pages/system/systemService.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/commonService.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/changeMoneyToChinese.js"></script>
<script type="text/javascript" src="/dist/plugins/print/print.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
    $(function () {
        $("body").on("click", ".moreList", function (e) {
            var tableName = $(this).attr("data-table");
            var column = $(this).attr("data-column");
            var columnName = $(this).attr("data-columnName");
            var mainKey = $(this).attr("data-column");
            var mid = $(this).attr("data-mid");
            var type = $(this).attr("data-type");
            if ($(this).hasClass("jiaobiao3")) {
                $.dialog({
                    content: 'url:/page/logs/logs.html?tableName=' + tableName + '&column=' + column + '&columnName=' + columnName + "&mainKey=" + mainKey + "&mid=" + mid + '&type=' + type + '&id=' + app.id,
                    title: '修改日志',
                    width: 600,
                    height: 500,
                    max: false,
                    min: false,
                    lock: true
                });
            }
        });
        $("body").on("click", ".moreListData", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".moreListData").hide();
        });
    });
</script>
<script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    function refresh() {

    }
    // 注册一个局自定义指令 `v-inputOnce`
    Vue.directive('onedate', {
        // 当被绑定的元素插入到 DOM 中时……
        update: function (el, binding) {
            // 聚焦元素
            if (app.pageType != 'add') {
                if (el.value == "NaN.undefined" || el.value == "") {
                    el.value = binding.value
                }
            }
        },
        componentUpdated: function (el, binding) {
            // 聚焦元素


        }
    })

    var app = new Vue({
        el: "#app",
        data: {
            wyp:false,
            id: $.wyui.page.urlParams.id,
            currentUser: getCurrentUser(),
            pageType: "edit",
            money:{
                auditors:[
                    new Money.PayAudit(),
                    new Money.PayAudit(),
                    new Money.PayAudit()
                ],
            },
            isAdd:$.wyui.page.urlParams.isAdd,
            selectIds:$.wyui.page.urlParams.selectIds,
        },
        methods: {
            save:function () {
                var that = this;
                if(that.selectIds.length==0){
                    alert('请选择要提交的用款申请');
                    return;
                }
                $.wyui.postMethod(urlConfig.apply.money.allCommit,
                    {userId:getCurrentUser().id,selectIds:that.selectIds,auditors:that.money.auditors},
                    function (data) {
                        alert('提交成功');
                        parent.refresh();
                        api.close();
                        that.selectIds = '';
                    })
            },
            addItem: function (prop, className) {
                this.money[prop].push(new Money[className]());
                if (className == 'Payee') {
                    setTimeout(function () {
                        initUserComplete();
                    }, 300);
                } else {
                    setTimeout(function () {
                        initAutoComplete();
                    }, 300);
                }
            },
            delItem: function (prop, i, desc) {
                if (this.money[prop].length <= 1) {
                    alert("请至少保留一位审核人！")
                    return
                }
                this.money[prop].splice(i, 1);
            },
        },

        mounted: function () {
            var that = this;
            if(server.fwq){
                if(server.fwq=="wyp"){
                    this.wyp=true;
                }
            }
        }

    });
</script>
<script>
    $(function () {
        initAutoComplete();
        initUserComplete();
    });

    function initAutoComplete() {
        $(".payAuditorName,.auditorName,.copier,.returnPayee").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                if ($(this).hasClass("auditorName")) {
                    var idx = $(this).attr("idx");
                    app.money.auditors[idx].auditorId = user.id;
                    app.money.auditors[idx].auditorName = user.roleName + "-" + user.name;
                } else if ($(this).hasClass("copier")) {
                    var userIds = new Array();
                    for (var i = 0; i < app.money.auditors.length; i++) {
                        userIds.push(app.money.auditors[i].auditorId);
                    }
                    for (var i = 0; i < app.money.copiers.length; i++) {
                        userIds.push(app.money.copiers[i].copyPersonId);
                    }
                    if ($.inArray(user.id, userIds) == -1) {
                        app.money.copiers.push({copyPersonId: user.id, copyPersonName: user.name});
                    } else {
                        alert("审核人、抄送人不能重复输入");
                    }
                    $(this).val("");
                } else if ($(this).hasClass("returnPayee")) {
//                    app.money.main.returnPayeeId = user.id;
//                    app.money.main.returnPayeeName = user.name;
//                    app.money.main.returnPayeeRoleName = user.roleName;
                }
                return false;
            },
            height: 210,
            width: 300
        });
    }

    function initUserComplete() {
        $(".payeeName").autoComplete({
            url: server.ip + urlConfig.apply.money.getPayeeList,
            render: function (users, panel) {
                if (users) {
                    for (var i = 0; i < users.length; i++) {
                        $("<li></li>").data("autoComplete",
                            users[i]).html("<a>" + users[i].payeeName + "&nbsp;&nbsp;&nbsp;" +
                            "(" + "&nbsp;" + users[i].bankName + ") " + "</a>")
                            .appendTo(panel);
                    }
                }
            },
            selected: function (user) {
                console.log(app.money.payees)
                var payee = {
                    id: user.id,
                    payeeName: user.payeeName,
                    bankName: user.bankName,
                    bankCardNumber: user.bankCardNumber
                }
                app.money.payees.splice(app.payeePosition, 1, payee)
                // app.money.main.payeeId = user.id;
                // app.money.main.payeeName = user.payeeName;
                // app.money.main.bankName = user.bankName;
                // app.money.main.bankCardNumber = user.bankCardNumber;
                return false;
            },
            //extraParams: {createUserId: getCurrentUser().id},
            height: 210,
            width: 300
        });
    }
</script>
</body>
</html>